﻿@model PhoneBilling.Models.TraiffModel
@{
    ViewBag.Title = "费率管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script type="text/javascript">
    function changeTraiff() {
        window.location.href = "/Manage/Traiff/" + $("#traffList").val();
    }

    function modifyTraiffDetail(id) {
        
        window.location.href = "/Manage/TraiffDetail?tariffID=" + $("#traffList").val() + "&areaCode=" + id;
    }

    function deleteTraiffDetail(id) {
        var msg = "确定删除费率(区号"+id+")？";
        var result = confirm(msg);
        if (result==true)
            window.location.href = "/Manage/DeleteTraiffDetail?tariffID=" + $("#traffList").val() + "&areaCode=" + id;
    }
    function se() {
        window.location.href = "/Manage/Traiff?id=" + $("#traffList").val() + "&area=" + $(".se").val();
    }
    function del(id, name) {
        var r = confirm("确认删除区号：" + name + "吗？");
        if (r == true) {
            window.location.href = "/Manage/DeleteTraiffDetail?tariffID=" + id + "&areaCode="+name;
        }
        return false;
    }
</script>
@if (Model.Message != null){<h2>@Model.Message</h2>}
<p id="btn-create" class="box">当前费率表: @Html.DropDownListFor(m => m.CurrentTraiff, new SelectList(Model.TraiffList, "ID", "Name"), new { id = "traffList", style = "input-text", onchange = "changeTraiff()" })  <a href=@string.Format("{0}?tariffID={1}","/Manage/TraiffDetail" , Model.CurrentTraiff)><span>新增费率明细</span></a></p>
@using (Html.BeginForm())
{
     @Html.HiddenFor(m => m.CurrentTraiff)
     @Html.LabelFor(m => m.区号)
     @Html.TextBoxFor(m => m.区号, new { @class ="se" })
    <input type="button" value="搜索" class="input-submit" onclick="se()" /> 
}
@{
    var grid = new WebGrid(source: Model.TraiffDetailList, rowsPerPage: 30);
}
@grid.GetHtml(
    alternatingRowStyle: "bg",
    columns:grid.Columns
    (
        grid.Column("区号", "区号"),
        grid.Column("地名", "地名"),
        grid.Column("话类", "话类"),
        grid.Column("基本费", "基本费"),
        grid.Column("附加费", "附加费"),
        grid.Column("服务费", "服务费"),
        grid.Column("基本费计次秒", "基本费计次秒"),
        grid.Column("服务费计次秒", "服务费计次秒"),
        grid.Column("分段计费方法", "分段计费方法"),
        grid.Column(format: (item) => Html.ActionLink("修改", "TraiffDetail", new {tariffID = Model.CurrentTraiff, areaCode = item.区号 })),
        grid.Column(format: (item) => Html.Raw(string.Format("<a href='javascript:' onclick=\"del('{0}','{1}')\">删除</a>", Model.CurrentTraiff, item.区号)))
    )
)
@*<table>
    <tr>
        <th>区号</th>
        <th>地名</th>
        <th>话类</th>
        <th>基本费</th>
        <th>附加费</th>
        <th>服务费</th>
        <th>基本费计次秒</th>
        <th>服务费计次秒</th>
        <th>分段计费方法</th>
        <th></th>
        <th></th>
    </tr>
    @{
        foreach (var detail in Model.TraiffDetailList)
        {
        <tr>
            <td>@detail.区号</td>
            <td>@detail.地名</td>
            <td>@detail.话类</td>
            <td>@detail.基本费</td>
            <td>@detail.附加费</td>
            <td>@detail.服务费</td>
            <td>@detail.基本费计次秒</td>
            <td>@detail.服务费计次秒</td>
            <td>@detail.分段计费方法</td>
            <td><input type="button" value="修改" class="input-submit-02" onclick="modifyTraiffDetail('@detail.区号')" /></td>
            <td><input type="button" value="删除" class="input-submit-02" onclick="deleteTraiffDetail('@detail.区号')" /></td>
        </tr>
        }
    }
</table>*@
